﻿using Microsoft.AspNetCore.Mvc;
using ZR.Admin.WebApi.Filters;
using ZR.Model.Dto.Business.ProductionControl;
using ZR.Model.Models.ProductionControl;
using ZR.Service.IService.ProductionControl;

//创建时间：2025-07-01
namespace ZR.Admin.WebApi.Controllers
{
    /// <summary>
    /// 产能报表
    /// </summary>
    [Verify]
    [Route("business/CksCapacityreport")]
    [ApiExplorerSettings(GroupName = "business")]
    public class CksCapacityreportController : BaseController
    {
        /// <summary>
        /// 产能报表接口
        /// </summary>
        private readonly ICksCapacityreportService _CksCapacityreportService;

        public CksCapacityreportController(ICksCapacityreportService CksCapacityreportService)
        {
            _CksCapacityreportService = CksCapacityreportService;
        }

        /// <summary>
        /// 查询产能报表列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "ckscapacityreport:list")]
        public IActionResult QueryCksCapacityreport([FromQuery] CksCapacityreportQueryDto parm)
        {
            var response = _CksCapacityreportService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询产能报表详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "ckscapacityreport:query")]
        public IActionResult GetCksCapacityreport(long Id)
        {
            var response = _CksCapacityreportService.GetInfo(Id);

            var info = response.Adapt<CksCapacityreportDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加产能报表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "ckscapacityreport:add")]
        [Log(Title = "产能报表", BusinessType = BusinessType.INSERT)]
        public IActionResult AddCksCapacityreport([FromBody] CksCapacityreportDto parm)
        {
            var modal = parm.Adapt<CksCapacityreport>().ToCreate(HttpContext);

            var response = _CksCapacityreportService.AddCksCapacityreport(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新产能报表
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "ckscapacityreport:edit")]
        [Log(Title = "产能报表", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateCksCapacityreport([FromBody] CksCapacityreportDto parm)
        {
            var modal = parm.Adapt<CksCapacityreport>().ToUpdate(HttpContext);
            var response = _CksCapacityreportService.UpdateCksCapacityreport(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除产能报表
        /// </summary>
        /// <returns></returns>
        [HttpDelete("delete/{ids}")]
        [ActionPermissionFilter(Permission = "ckscapacityreport:delete")]
        [Log(Title = "产能报表", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteCksCapacityreport([FromRoute] string ids)
        {
            var idArr = Tools.SplitAndConvert<long>(ids);

            return ToResponse(_CksCapacityreportService.Delete(idArr));
        }

    }
}